﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.Rendering.SortingSettings
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System;

#nullable disable
namespace UnityEngine.Rendering
{
  /// <summary>
  ///   <para>This struct describes the methods to sort objects during rendering.</para>
  /// </summary>
  public struct SortingSettings : IEquatable<SortingSettings>
  {
    private Matrix4x4 m_WorldToCameraMatrix;
    private Vector3 m_CameraPosition;
    private Vector3 m_CustomAxis;
    private SortingCriteria m_Criteria;
    private DistanceMetric m_DistanceMetric;
    private Matrix4x4 m_PreviousVPMatrix;
    private Matrix4x4 m_NonJitteredVPMatrix;

    /// <summary>
    ///   <para>Create a sorting settings struct.</para>
    /// </summary>
    /// <param name="camera">The camera's transparency sort mode is used to determine whether to use orthographic or distance based sorting.</param>
    public SortingSettings(Camera camera)
    {
      ScriptableRenderContext.InitializeSortSettings(camera, out this);
      this.m_Criteria = this.criteria;
    }

    /// <summary>
    ///   <para>Used to calculate the distance to objects.</para>
    /// </summary>
    public Matrix4x4 worldToCameraMatrix
    {
      get => this.m_WorldToCameraMatrix;
      set => this.m_WorldToCameraMatrix = value;
    }

    /// <summary>
    ///   <para>Used to calculate the distance to objects.</para>
    /// </summary>
    public Vector3 cameraPosition
    {
      get => this.m_CameraPosition;
      set => this.m_CameraPosition = value;
    }

    /// <summary>
    ///   <para>Used to calculate distance to objects, by comparing the positions of objects to this axis.</para>
    /// </summary>
    public Vector3 customAxis
    {
      get => this.m_CustomAxis;
      set => this.m_CustomAxis = value;
    }

    /// <summary>
    ///   <para>What kind of sorting to do while rendering.</para>
    /// </summary>
    public SortingCriteria criteria
    {
      get => this.m_Criteria;
      set => this.m_Criteria = value;
    }

    /// <summary>
    ///   <para>Type of sorting to use while rendering.</para>
    /// </summary>
    public DistanceMetric distanceMetric
    {
      get => this.m_DistanceMetric;
      set => this.m_DistanceMetric = value;
    }

    public bool Equals(SortingSettings other)
    {
      return this.m_WorldToCameraMatrix.Equals(other.m_WorldToCameraMatrix) && this.m_CameraPosition.Equals(other.m_CameraPosition) && this.m_CustomAxis.Equals(other.m_CustomAxis) && this.m_Criteria == other.m_Criteria && this.m_DistanceMetric == other.m_DistanceMetric && this.m_PreviousVPMatrix.Equals(other.m_PreviousVPMatrix) && this.m_NonJitteredVPMatrix.Equals(other.m_NonJitteredVPMatrix);
    }

    public override bool Equals(object obj)
    {
      return obj != null && obj is SortingSettings other && this.Equals(other);
    }

    public override int GetHashCode()
    {
      return ((int) ((DistanceMetric) ((int) ((SortingCriteria) (((this.m_WorldToCameraMatrix.GetHashCode() * 397 ^ this.m_CameraPosition.GetHashCode()) * 397 ^ this.m_CustomAxis.GetHashCode()) * 397) ^ this.m_Criteria) * 397) ^ this.m_DistanceMetric) * 397 ^ this.m_PreviousVPMatrix.GetHashCode()) * 397 ^ this.m_NonJitteredVPMatrix.GetHashCode();
    }

    public static bool operator ==(SortingSettings left, SortingSettings right)
    {
      return left.Equals(right);
    }

    public static bool operator !=(SortingSettings left, SortingSettings right)
    {
      return !left.Equals(right);
    }
  }
}
